package com.example.pricecloudperformancetesting.service;


import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * @author Remy
 * @description :
 * @date 2020-05-26 11:46
 */
public class TCPClient {

    public static void main(String[] args) {
        try {
            Socket socket = new Socket("127.0.0.1", 9999);

            OutputStream out = socket.getOutputStream();
            DataOutputStream dataOutputStream = new DataOutputStream(out);
            dataOutputStream.writeUTF("testyixia");
            dataOutputStream.flush();

            InputStream is = socket.getInputStream();
            byte[] bytes = new byte[1024];
            int len;
            while ((len = is.read(bytes)) != -1) {
                System.out.println(new String(bytes, 0, len));
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
